<template>
  <basic-container>
    <avue-crud v-bind="bindVal"
               v-on="onEvent"
               :page.sync="page"
               v-model="form">
      <template slot="menu"
                slot-scope="{row,type,size}">
        <el-button :size="size"
                   :type="type"
                   icon="el-icon-setting"
                   v-if="row.isEffect === 1 && (permission.takeEffectCodeShow===undefined?false:permission.takeEffectCodeShow)"
                   @click="rowEffect(row)">生效</el-button>
      </template>
      <template slot="menuLeft">

        <el-button type="danger" v-if="permission.delCodeShow===undefined?false:permission.delCodeShow" icon="el-icon-delete" size="small" @click.stop="deletes()">批量删除</el-button>

        <el-button size="small"
                   icon="el-icon-setting"
                   v-if="permission.effectAllCodeShow===undefined?false:permission.effectAllCodeShow"
                   @click="effectAll">生效全部</el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>

<script>
import { effect, effectAll } from '@/api/system/params'
export default window.$crudCommon({
  data () {
    return {
      edit: false,
      del: false,
      isShowEffectAll: false,
      isShowEffect: false
    }
  },
  created () {
  },
  methods: {
    effectAll () {
      this.$confirm('此操作将生效全部参数, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        return effectAll()
      }).then(() => {
        this.$message.success('全部参数生效成功')
        this.getList();
      })
    },
    rowEffect (row) {
      this.$confirm('此操作将生效参数, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        return effect(row.code)
      }).then(() => {
        this.$message.success('生效成功')
        this.getList();
      })
    },
  }
}, {
  name: '/system/params',
  data: 'list'
})
</script>

<style lang="scss" scoped>
</style>